﻿@using ExcellentCRM.DataService.Models
@model ExcellentCRM.Site.Models.StuClientModel

@{
    Layout = null;
}
<style type="text/css">
    #saveForm .dk_toggle {
        min-width: 150px;
    }
</style>
@using (Ajax.BeginForm("CreateOrUpdate", null, new AjaxOptions
    {
        HttpMethod = "post",
        OnSuccess = "saveSucc"
    },
    new {@class = "form-horizontal", id = "saveForm"}))
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)
    @Html.ValidationMessageFor(m => m.StudentInfo.StuName)
    @Html.ValidationMessageFor(m => m.StudentInfo.Phone)
    @Html.ValidationMessageFor(m => m.StudentInfo.CellPhone)
    @Html.ValidationMessageFor(m => m.StudentInfo.Email)
    <div id="alertContain" class="alert alert-error fade in hide">
        <button type="button" class="close" data-dismiss="alert">&times;</button>
        <div class="alert-content"></div>
    </div>
    <div class="row-fluid">
        <div class="span6">
            <div class="control-group">
                @Html.LabelFor(m => m.StudentInfo.StuName, new { @class = "control-label" })
                <div class="controls">
                    @Html.TextBoxFor(m => m.StudentInfo.StuName, null, new {placeholder = "姓名"})
                </div>
            </div>
            <div class="control-group">
                @Html.LabelFor(m => m.StudentInfo.Email, new { @class = "control-label" })
                <div class="controls">
                    @Html.TextBoxFor(m => m.StudentInfo.Email, null, new {placeholder = "Email"})
                </div>
            </div>
            <div class="control-group">
                @Html.LabelFor(m => m.StudentInfo.CompanyName, new { @class = "control-label" })
                <div class="controls">
                    @Html.TextBoxFor(m => m.StudentInfo.CompanyName, null, new {placeholder = "公司名称"})
                </div>
            </div>
            <div class="control-group">
                @Html.LabelFor(m => m.StudentInfo.Profession, new { @class = "control-label" })
                <div class="controls">
                    @Html.TextBoxFor(m => m.StudentInfo.Profession, null, new {placeholder = "行业"})
                </div>
            </div>
            <div class="control-group">
                @Html.LabelFor(m => m.StudentInfo.Position, new { @class = "control-label" })
                <div class="controls">
                    @Html.TextBoxFor(m => m.StudentInfo.Position, null, new {placeholder = "职务"})
                </div>
            </div>
        </div>
        <div class="span6">
            <div class="control-group">
                @Html.LabelFor(m => m.StudentInfo.CellPhone, new { @class = "control-label" })
                <div class="controls">
                    @Html.TextBoxFor(m => m.StudentInfo.CellPhone, null, new {placeholder = "手机"})
                </div>
            </div>
            <div class="control-group">
                @Html.LabelFor(m => m.StudentInfo.Phone, new { @class = "control-label" })
                <div class="controls">
                    @Html.TextBoxFor(m => m.StudentInfo.Phone, null, new {placeholder = "电话"})
                </div>
            </div>
            <div class="control-group">
                @Html.LabelFor(m => m.StudentInfo.QQNumber, new { @class = "control-label" })
                <div class="controls">
                    @Html.TextBoxFor(m => m.StudentInfo.QQNumber, null, new {placeholder = "QQ号码"})
                </div>
            </div>
            <div class="control-group">
                @{
                    var genderList = new SelectList(StudentInfo.GenderTypeDic, "Key", "Value");
                }
                @Html.LabelFor(m => m.StudentInfo.Gender, new { @class = "control-label" })
                <div class="controls">
                    @Html.DropDownListFor(m => m.StudentInfo.Gender, genderList, "选择")
                </div>
            </div>
            <div class="control-group">
                @Html.LabelFor(m => m.StudentInfo.DateOfBirth, new { @class = "control-label" })
                <div class="controls">
                    @Html.TextBoxFor(m => m.StudentInfo.DateOfBirth, null, new { placeholder = "出生日期", @readonly = "readonly" })
                </div>
            </div>
        </div>
    </div>
    <div class="row-fluid">
        <div class="span12">
            <div class="control-group">
                @Html.LabelFor(m => m.StudentInfo.CompanyAddress, new { @class = "control-label" })
                <div class="controls">
                    @Html.TextBoxFor(m => m.StudentInfo.CompanyAddress, null, new { placeholder = "公司地址", @class = "input-xxlarge" })
                </div>
            </div>
            <div class="control-group">
                @Html.LabelFor(m => m.StudentInfo.HomeAddress, new { @class = "control-label" })
                <div class="controls">
                    @Html.TextBoxFor(m => m.StudentInfo.HomeAddress, null, new {placeholder = "家庭地址", @class = "input-xxlarge" })
                </div>
            </div>
        </div>
    </div>
    <div class="control-group hidden">
        <div class="controls">
            <input type="submit" value="保存" class="btn btn-primary"/>
            @Html.HiddenFor(m => m.Id)
        </div>
    </div>
}
<script type="text/javascript">
    $(function () {
        $.validator.unobtrusive.parse('#saveForm');
        $('#StudentInfo_DateOfBirth').datepicker({
            showAnim: 'slideDown'
        });
        $('#saveForm select').dropkick();
    });

    function saveSucc(result) {
        if (!result || (!result.success && !result.message)) {
            alert('保存失败，未知原因');
            return;
        }
        if (!result.success && result.message) {
            $('#alertContain .alert-content').html(result.message);
            $('#alertContain').removeClass('alert-success hide').addClass('alert-error').alert();
            return;
        }
        if (result.success) {
            $('#alertContain .alert-content').html('保存完成');
            $('#alertContain').removeClass('alert-error hide').addClass('alert-success').alert();
            $('#saveForm #Id').val(result.expandos.id);
        }
    }
</script>
